package com.admin.socketmultiplayer.fragment

import cn.bmob.v3.BmobUser
import com.admin.socketmultiplayer.R
import com.admin.socketmultiplayer.activity.SettingActivity
import com.admin.socketmultiplayer.bean.MyUser
import com.admin.socketmultiplayer.config.DataUtils
import kotlinx.android.synthetic.main.fragment_mine.view.*
import org.jetbrains.anko.support.v4.startActivity

/**
 * Created by 吴昶 on 2018/5/15.
 */
class UserFragment:BaseFragment(){

    var user: MyUser?=null

    override fun bindLayout(): Int {
        return R.layout.fragment_mine
    }

    override fun initData() {

    }

    override fun onResume() {
        super.onResume()
        initUserInfo()
    }

    override fun initEvent() {
        fview!!.iv_setting.setOnClickListener {
            startActivity<SettingActivity>()
        }
    }

    fun initUserInfo(){
        user= BmobUser.getCurrentUser(MyUser::class.java)
        fview!!.tv_user_name.text=user!!.username
        fview!!.tv_user_email.text=user!!.email
        fview!!.tv_user_phone.text=user!!.mobilePhoneNumber
        fview!!.tv_user_qq.text=user!!.QQ
        fview!!.tv_user_weichat.text=user!!.weChat
        DataUtils.showUserImage(activity!!,user!!.objectId,fview!!.iv_user_header)
    }
}